package org.jeecg.modules.job.ums.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.modules.job.ums.entity.UmsAccount;
import org.jeecg.modules.job.ums.mapper.UmsAccountMapper;
import org.jeecg.modules.job.ums.service.IUmsAccountService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.math.BigDecimal;

/**
 * @Description: 会员账户
 * @Author: jeecg-boot
 * @Date:   2022-12-23
 * @Version: V1.0
 */
@Service
public class UmsAccountServiceImpl extends ServiceImpl<UmsAccountMapper, UmsAccount> implements IUmsAccountService {

    @Override
    public void addMemberBalance(BigDecimal money, String memberId) {
        UmsAccount account=this.findByMemberId(memberId);
        account.setBalance(account.getBalance().add(money));
        this.updateById(account);
    }

    @Override
    public UmsAccount findByMemberId(String memberId) {
        return baseMapper.selectOne(new QueryWrapper(new UmsAccount().setMemberId(memberId)));
    }
}
